import torch

t1 = torch.rand(5, 3)

t2 = t1[1, :]
print(t2.shape)  # torch.Size([15])

t3 = t1[1:2, :]
print(t3.shape)  # torch.Size([1, 15])

print(torch.allclose(t2, t3, 1e-8))  # True  自动广播

print(torch.equal(t2, t3))  # False

print(torch.eq(t2, t3))  # tensor([[True, True, True]])